﻿using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace DiverseStudents.UI
{
    internal static partial class UICreate
    {
        public enum TextType
        {
            Tile,
            Round,
            Tips,
        }

        public enum TextProType
        {
            Desc,
            Reward,
            Content,
        }
        public static Text Text(string text ="",TextType type = TextType.Tips, string flag = "", int fontSize = 24, bool _show = true)
        {
            if (detailIntentView != null)
            {
                string typepath;
                switch (type)
                {
                    case TextType.Tips:
                        typepath = "txt_tips";
                        break;
                    case TextType.Tile:
                        typepath = "group_data/group_intent/txt_title";
                        break;
                    case TextType.Round:
                        typepath = "group_data/group_intent/group_round/txt_Round";
                        break;
                    default:
                        typepath =   "";
                        break;
                }

                var gi = detailIntentView.FindComponent<Text>(typepath);
                if (gi != null && gi != default)
                {
                    var ngi = GameObject.Instantiate(gi);
                    ngi.name = $"Mod_Text{flag}";
                    ngi.text = text;
                    ngi.fontSize = fontSize;
                    ngi.alignment = TextAnchor.MiddleLeft;
                    ngi.horizontalOverflow = HorizontalWrapMode.Overflow;
                    ngi.gameObject?.SetActive(_show);
                    return ngi;
                }
            }
            return CreateErrorT<Text>(flag);
        }

        public static TextMeshProUGUI TextRro(TextProType type = TextProType.Desc, string flag = "", bool _show = true)
        {
            if (detailIntentView != null)
            {
                string typepath;
                switch (type)
                {
                    case TextProType.Desc:
                        typepath = "group_data/group_intent/txtex_desc";
                        break;
                    case TextProType.Reward:
                        typepath = "group_data/group_intent/group_reward/txtex_reward";
                        break;
                    case TextProType.Content:
                        typepath = "group_data/group_intent/btn_finish/txtex_content";
                        break;
                    default:
                        typepath = "";
                        break;
                }

                var gi = detailIntentView.FindComponent<TextMeshProUGUI>(typepath);
                if (gi != null && gi != default)
                {
                    var ngi = GameObject.Instantiate(gi);
                    ngi.name = $"Mod_TextPro{flag}";
                    ngi.gameObject?.SetActive(_show);
                    return ngi;
                }
                
            }
            return CreateErrorT<TextMeshProUGUI>(flag);
        }

    }
}
